<template>
  <div>
    <van-nav-bar
      title="订单列表"
      left-text="返回"
      left-arrow
      @click-left="back"
    />

    <van-card
      v-for="(item, index) in purchaseList"
      :key="index"
      :num="item.quantity"
      :price="item.money + '.00'"
      :desc="item.insideKey"
      :title="item.name"
      :thumb="item.goodsImg"
    >
      <template #footer>
        <van-button size="mini" @click="details(item)">详情</van-button>
      </template>
    </van-card>
    
  </div>
</template>
<script>
import { fruitssOrderById } from "../common/Api/index.js";
export default {
  data() {
    return {
      purchaseList: [],
      form: {
        uid: "",
        distinguish: "购买",
      },
    };
  },
  mounted() {
    this.cartList();
  },
  methods: {
    details(item) {
      this.$router.push({
        name: "orderDetail",
        params: {
          item: item,
        },
      });
      console.log(item);
    },
    back() {
      this.$router.push("/");
    },
    cartList() {
      this.form.uid = JSON.parse(sessionStorage.getItem("information")).uid;
      fruitssOrderById(this.form).then((res) => {
        this.purchaseList = res;
        console.log(res);
      });
    },
  },
};
</script>